<template>
<!-- 产品库存报表 -->
  <div class="content">
    <div v-if="successFailure" v-loading="loading" class="content_box">
      <img src="@assets/icon/beforeSettle/shenhetongguo.png" alt="" />
      <p>已成功跳转至产品库存报表页</p>
    </div>
    <div v-else class="content_box">
      <img src="@assets/icon/beforeSettle/shenheshibai.png" alt="" />
      <p>暂未分配经销商，请去销售管理分配经销商</p>
    </div>
    <a ref="hrefLink" :href="hrefLink" target="_blank"></a>
  </div>
</template>
<script>
import {
BIsupplierInventory
} from '@api/m_mall_web_v1.js';
export default {
  data() {
    return {
      loading: false,
      accountNumber: '',
      auth: '',
      successFailure: true,
      hrefLink: '',
      productLineList:[],
      originalFactoryType:''
    };
  },
  mounted() {
    this.getOrderNotPaid();
  },
  methods: {
    getOrderNotPaid() {
      this.loading = true;
      this.$axios({
          method: 'post',
          url:BIsupplierInventory,
          data:{
            rfType:1
          }
      }).then(res=>{
           this.auth = res.data.payload.auth;
           this.productLineList = res.data.payload.productLineList
           this.originalFactoryType=res.data.payload.originalFactoryType
          if(this.originalFactoryType===0){
            // 其他
             this.hrefLink = `https://bi.gkht.com/WebReport/ReportServer?op=fr_bi&cmd=bi_init&id=127&openFromShare=true&systemManager=true&createBy=-999&auth=${this.auth}&产品线=${this.productLineList.join("','")}`;
             this.$nextTick(() => {
             this.$refs.hrefLink.click();
            });
          }else if(this.originalFactoryType===1){
            // 马尼原厂
             this.hrefLink = `https://bi.gkht.com/WebReport/ReportServer?op=fr_bi&cmd=bi_init&id=435&openFromShare=true&systemManager=true&createBy=-999&auth=${this.auth}&产品线=${this.productLineList.join("','")}`;
             this.$nextTick(() => {
             this.$refs.hrefLink.click();})
          }else {
            // 贝朗原厂
             this.hrefLink = `https://bi.gkht.com/WebReport/ReportServer?op=fr_bi&cmd=bi_init&id=476&openFromShare=true&systemManager=true&createBy=-999&auth=${this.auth}&product_line_code=${this.productLineList.join("','")}`;
             this.$nextTick(() => {
             this.$refs.hrefLink.click();})
          }
      })
      // this.$axios
      //   .$post('m-mall-center/api/v1/reportForm/getOriginalFactoryBiRFUrl')
      //   .then(res => {
      //     if (res.code === '0') {
      //       const { payload } = res;
      //       this.accountNumber = payload.accountNumber;
      //       this.auth = payload.auth;
      //       this.successFailure = !!payload.auth;
      //     }
      //     if (this.successFailure) {
      //       this.hrefLink = ``;
      //       this.$nextTick(() => {
      //         this.$refs.hrefLink.click();
      //       });
      //     }
      //   })
        .finally(() => {
          this.loading = false;
        });
    }
  }
};
</script>
<style lang="less">
.content {
  height: 100%;
  .content_box {
    margin-top: 150px;
    img {
      display: block;
      margin: 0 auto;
    }
    p {
      text-align: center;
      font-size: 28px;
      color: #333;
      font-weight: 550;
    }
  }
}
</style>
